package com.linfeng.component.common.exception;

import com.linfeng.component.common.response.ResponseEntity;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Order(Ordered.HIGHEST_PRECEDENCE)
public class CustomControllerAdvice {

    @ExceptionHandler(value = {CustomException.class})
    public ResponseEntity customException(CustomException e) {

        return new ResponseEntity(e);
    }

    @ExceptionHandler(value = {Exception.class})
    public ResponseEntity exception(Exception e) {

        return new ResponseEntity(1000, e.getMessage());
    }
}
